%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;

% ESTIMATING Full MODEL PARAMETERS			       		;
% T and F0 are now known at time=0                      ;
% T and F0 can now be correlated                        :
% Multi-Stage Optimization                              ;
% Oct 20, 2014 -- Paulina Oliva & Chris Severen         ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;

clear all;
warning off all;
format compact
format shortg

load results.mat

%*******************************************************;
% Execution and Optimization Options                    ;
%*******************************************************;

rp.cc      = Inf; % Convergence criterion

%*******************************************************;
% Function call, start min                              ;
%*******************************************************;
    
if rp.parl==1
    matlabpool('open',rp.cores)
end

options= ...
    optimset('Display','iter','MaxFunEvals',10000,'TolFun',1e-10);

params = [];
stage  = [];

[theta_hat2,value2,flag2,info2] = fminsearch('Full_Likelihood',theta_hat,...
    options,DP,I_N,A,R,TG,MON,params,rp,snPass,stage);

if rp.parl==1
    matlabpool close
end

save resultsFMIN.mat



